<template>
  <div>

    <NuxtLink to="/about">
      关于我们
    </NuxtLink>
    <NuxtLink to="/lend">
      我要投资
    </NuxtLink>
    <NuxtLink to="/user">
      用户中心
    </NuxtLink>
    <a href="http://www.baidu.com" target="_blank">百度</a>

    <h1>Home page</h1>
    <span>ip: {{ip}}</span>
  </div>
</template>

<script>
export default {
  name: "index",
  data(){
    return {
      ip: null
    }
  },
  // Nuxt 提供额外的方法, 服务端执行
  // 页面被访问时服务器中执行
  async asyncData({ $axios }) {
    console.log('asyncData')
    // let response = await $axios.$get('http://icanhazip.com')
    let response = await $axios.$get('/')
    return {
      ip: response,
    }
  },
  // get 需要解析数据, $get 接收的是响应的数据
  created() {
    // this.$axios.$get("http://icanhazip.com").then((response) => {
    //   console.log(response);
    //   this.ip = response
    // })
  },
  methods: {

  }
}
</script>

<style scoped>

</style>